# -*- coding: utf-8 -*-
# __init__.py create by kumiler
# on 2022/8/23 16:26
# desc

from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from spmi.ods.mysql.spmi import spmi_ods__spmi_opt_refund_bill

executeDay = '{{ var.value.spmi_mark }}'
spmi_dwd__dwd_spmi_opt_refund_bill_base_dt= SparkSqlOperator(
    task_id='spmi_dwd__dwd_spmi_opt_refund_bill_base_dt',
    email=['lukunming@jtexpress.com', 'yl_bigdata@yl-scm.com'],
    master='yarn',
    name='spmi_dwd__dwd_spmi_opt_refund_bill_base_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='spmi/dwd/spmi/dwd_spmi_opt_refund_bill_base_dt/execute.sql',
    pool_slots=2,
    executor_cores=4,
    executor_memory='6G',
    num_executors=16,
    driver_cores=12,
    driver_memory='24G',
    conf={'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
          'spark.dynamicAllocation.maxExecutors': 25,
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 30,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.executor.memoryOverhead': '2G',
          'spark.yarn.maxAppAttempts': 1,
          'spark.sql.shuffle.partitions': 100
          },
    hiveconf={'hive.exec.dynamic.partition': 'true',  # 动态分区
              'hive.exec.dynamic.partition.mode': 'nonstrict',
              'hive.exec.max.dynamic.partitions': 300,  # 最大分区
              'hive.exec.max.dynamic.partitions.pernode': 300,  # 最大分区
              },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=50),
    retries=2,
)

spmi_dwd__dwd_spmi_opt_refund_bill_base_dt << spmi_ods__spmi_opt_refund_bill
